/**
 * Created by meiguizhinian on 2018/6/21
 * Copyright © 2018 lixiaolong. All rights reserved.
 */

unblockme.HomeScene = LLScene.extend({
	res : [
		"res/game/UnblockMe/NETDATA/Scene/scene.config",
		"res/game/UnblockMe/NETDATA/gameaction.bin",
		"res/game/UnblockMe/NETDATA/UI/uiform.bin",
		"res/game/UnblockMe/NETDATA/UI/uicontrol.bin",

		"res/game/UnblockMe/NETDATA/ANIMATION/Home.actor",

		"res/game/UnblockMe/vfs/logo.png",
		"res/game/UnblockMe/vfs/bg_yellow.png",
		"res/game/UnblockMe/vfs/play.png",
		"res/game/UnblockMe/vfs/menu.png",
		"res/game/UnblockMe/vfs/rate.png",
		"res/game/UnblockMe/vfs/sound_on.png",
		"res/game/UnblockMe/vfs/sound_off.png",
		//music
		"res/game/UnblockMe/audio/music/bird.mp3",
		"res/game/UnblockMe/audio/effect/ready_go.mp3",
		//评价界面
		"res/game/UnblockMe/vfs/rate_bg.png",
		"res/game/UnblockMe/vfs/rate_star_front.png",
		"res/game/UnblockMe/vfs/rate_star_back.png",
		"res/game/UnblockMe/vfs/rate_title.png",
	],
	ctor : function (form, space=null) {
		this._super(form, space);

		ivy.SoundManager.getInstance().playMusic("audio/music/bird.mp3");

		let button_play = this._formNode.getChildByName("bt1");
		button_play.setTouchEndCallback(function() {
			cc.LoaderScene.preload(unblockme.GameScene.prototype.res, function () {
				let progress = unblockme.Recorder.getProgress();
				let scene = unblockme.GameScene.create("Game");
				scene.select(progress);
				cc.director.runScene(scene);
			}, this);
		});
		let button_menu = this._formNode.getChildByName("bt2");
		button_menu.setTouchEndCallback(function() {
			//advertise 6.封面，每次进入游戏，第一次点击关卡按钮，调用一次大屏广告
			// Advertise::showFullFirst(IvySDK::AD_POS_GAME_PASSLEVEL);
			cc.LoaderScene.preload(unblockme.GateScene.prototype.res, function () {
				let scene = unblockme.GateScene.create("Gate");
				cc.director.runScene(scene);
			}, this);
		});

		let button_rate = this._formNode.getChildByName("bt3");
		button_rate.setTouchEndCallback(function() {
			/*
			let dialog = unblockme.RateDialog.create("Rate");
			this.showDialog(dialog);
			/*/
			cc.LoaderScene.preload(unblockme.TestScene.prototype.res, function () {
				let scene = unblockme.TestScene.create("Test");
				cc.director.runScene(scene);
			}, this);
			//*/
		}.bind(this));

		LLNodeHelper.registerAudioButton(this._formNode, "bt4");
	},
});

unblockme.HomeScene.create = function (form, space=null) {
	return new unblockme.HomeScene(form, space);
};